﻿using System;
using System.Activities;
using System.Activities.Presentation;
using System.ComponentModel;
using System.Drawing;
using WFExtended.Activities.Designers;

namespace WFExtended.Activities
{
    /// <summary>
    /// Get Worklow Instance ID
    /// <code>
    /// <b>Xaml Example with a CSharpExpression : </b> <br /> <br/>
    /// <Activity
    /// xmlns:wa="clr-namespace:WFExtended.Activities;assembly=WFExtended"> <br/>
    /// &nbsp;<wa:GetWorkflowID> <br/>
    /// &nbsp;&nbsp;<wa:GetWorkflowID.WorkflowID> <br/>
    /// &nbsp;&nbsp;&nbsp;<OutArgument x:TypeArguments="s:Guid"> <br/>
    /// &nbsp;&nbsp;&nbsp;&nbsp;<mca:CSharpReference x:TypeArguments="s:Guid">WorkflowID</mca:CSharpReference> <br/>
    /// &nbsp;&nbsp;&nbsp;</OutArgument> <br/>
    /// &nbsp;&nbsp;</wa:GetWorkflowID.WorkflowID> <br/>
    /// &nbsp;</wa:GetWorkflowID> <br/>
    /// </Activity> <br/><br/>
    /// </code>
    /// </summary>
    [Description("Get Worklow Instance ID")]
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.GetWorkflowIDToolbox.bmp")]
    [Designer(typeof(GetWorkflowIDDesigner))]
    public sealed class GetWorkflowID : NativeActivity
    {
        /// <summary>
        /// Get or Set the Workflow Instance Guid
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        [Browsable(true)]
        [RequiredArgument]
        [Description("Get or Set the Workflow Instance Guid")]
        public OutArgument<Guid> WorkflowID { get; set; }

        /// <summary>
        /// uns the activity’s execution logic.
        /// </summary>
        /// <param name="context">The execution context in which the activity executes</param>
        protected override void Execute(NativeActivityContext context)
        {
            WorkflowID.Set(context, context.WorkflowInstanceId);
        }
    }
}
